<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String root = request.getContextPath();
	String sessionId = (String)session.getAttribute("userid");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function blankChk() {
	var form = document.loginForm;
	if (form.userid.value == "") {
		alert("아이디를 입력하세요");
		form.userid.focus();
		return false;
	}

	if (form.userpass.value == "") {
		alert("비밀번호를 입력하세요");
		form.userpass.focus();
		return false;
	}
	
	form.submit();
	return;
}
</script>
<title>메인화면</title>
</head>
<body>
<h1>메인화면</h1>
<form action="login.do" name="loginForm" method="post" onsubmit="return blankChk()">
	<% if(sessionId!=null) { %>
		<table border="1">
			<tr>
				<td> ${ requestScope.result} </td>
			</tr>
			<tr>
				<td align="center">
					<a href=>정보변경</a>
					<a href="login/logout.jsp">로그아웃</a><br/>
				</td>
			</tr>
		</table>
	<% }  else { %>
		<table border="1">
			<tr>
				<td>아이디</td>
				<td><input type="text" id="userid" name="userid" maxlength="13" style="width: 100px;"/></td>
				<td rowspan="2"><input type="submit" value="로그인"></input></td>
			</tr>
			<tr>
				<td>비밀번호</td>
				<td><input type="password" id="userpass" name="userpass" maxlength="13" style="width: 100px;"/></td>
			</tr>
			<tr>
				<td colspan="3" align="center"><a href="signup/signup_form.jsp">회원가입</a><br/></td>
			</tr>
		</table>
		<% } %>
	<a href="<%=root %>/list.do">게시판</a>
</form>
</body>
</html>